import django_filters
from oncall.models import OncallInfo


class OncallInfoFilter(django_filters.FilterSet):
    dev_group = django_filters.CharFilter(field_name='dev_group', lookup_expr='exact')
    start_time = django_filters.DateFilter(field_name='start_time', lookup_expr='icontains')
    end_time = django_filters.DateFilter(field_name='end_time', lookup_expr='icontains')

    class Meta:
        model = OncallInfo
        # 搜索字段
        fields = ('dev_group', 'start_time', 'end_time')

# import django_filters
#
# from .models import *
#
#
# class OncallInfoFilter(django_filters.rest_framework.FilterSet):
#     """
#     过滤器
#     """
#
#     dev_group = django_filters.CharFilter(name='dev_group', label='组', help_text='组')
#     start_time = django_filters.DateTimeFilter(name='start_time', label='开始时间', help_text='开始时间')
#     end_time = django_filters.DateTimeFilter(name='end_time', label='结束时间', help_text='结束时间')
#
#     class Meta:
#         model = OncallInfo
#         fields = ['dev_group', 'start_time', 'end_time']